//----------------------------------------------------------------------------
// M A R I T I M E  R E S E A R C H  I N S T I T U T E  N E T H E R L A N D S
//----------------------------------------------------------------------------
// Copyright (C) 2012 - MARIN - All rights reserved - http://www.marin.nl
//----------------------------------------------------------------------------
// Program    : mermaid
// Module     : vbm
// File       : shiftzetaphi_kernels.h
// Author     : M.A. de Jong
//----------------------------------------------------------------------------

#ifndef SHIFTZETAPHI_KERNELS_H
#define SHIFTZETAPHI_KERNELS_H

namespace wavescomputer
{

template <class T>
__global__ void kernel_shiftzetaphi(T* zetam2, T* zetam1, const T* zeta,
                                    T* phim2,  T* phim1,  const T* phi,
                                    T* dt_zetam1, const T* dt_zeta,
                                    T* dt_phim1,  const T* dt_phi,
                                    const T eps,  const int ld)
{
    int u = bx * Bx + tx;
    int v = by * By + ty;
    int tid = v * ld + u;

    zetam2[tid] = zetam1[tid];
    zetam1[tid] = zeta  [tid];
    phim2 [tid] = phim1 [tid];
    phim1 [tid] = phi   [tid];

    // only needed when smoothZetaPhi() is used, i.e., eps > 0.
    if (eps > 0.0)
    {
        dt_zetam1[tid] = dt_zeta[tid];
        dt_phim1 [tid] = dt_phi [tid]; 
    }
}

} // namespace wavescomputer

#endif // SHIFTZETAPHI_KERNELS_H
